﻿//using System.Web.Mvc;
//using Micua.Core.Configuration;
//using Micua.Model.Struct;
//using Micua.Utility;

//namespace Micua.Extension
//{
//    /// <summary>
//    /// HtmlHelper拓展类(Culture)
//    /// </summary>
//    public static class Culture
//    {
//        #region 获取语言化字符串 +static string GetCultureString(this HtmlHelper htmlHelper, string key)
//        /// <summary>
//        /// 获取语言化字符串
//        /// </summary>
//        /// <param name="htmlHelper">HtmlHelper</param>
//        /// <param name="key">原文键</param>
//        /// <returns>语言化字符串</returns>
//        public static string GetCultureString(this HtmlHelper htmlHelper, string key)
//        {
//            //var vPath = string.Format("~/Content/Culture/lang.{0}.resources", Setting.Get(Setting.Key.site_culture));
//            //var fPath = htmlHelper.ViewContext.HttpContext.Server.MapPath(vPath);
//            //if (!File.Exists(fPath)) fPath = htmlHelper.ViewContext.HttpContext.Server.MapPath("~/Content/Culture/lang.resources");
//            //if (!File.Exists(fPath)) return key;

//            //using (ResourceSet set = new ResourceSet(fPath))
//            //{
//            //    //CacheHelper.SetCache(vPath, set);
//            //    return set.GetString(key);
//            //}
//            //#region 2
//            ////string resourcetype;
//            ////byte[] resourcedata;
//            ////using (var reader = CacheHelper.GetCache<ResourceReader>(vPath) ?? new System.Resources.ResourceReader(Server.MapPath(vPath)))
//            ////{
//            ////    reader.GetResourceData(key, out resourcetype, out resourcedata);
//            ////    CacheHelper.SetCache(vPath, reader);
//            ////}

//            //////去掉第一个字节，无用
//            ////byte[] arr = new byte[resourcedata.Length - 1];
//            ////for (int i = 0; i < arr.Length; i++)
//            ////{
//            ////    arr[i] = resourcedata[i + 1];
//            ////}
//            ////return System.Text.Encoding.UTF8.GetString(arr); 
//            //#endregion
//            return key.GetCultureString(Setting.GetString(OptionKeys.SiteCulture));
//        }
//        #endregion
//    }
//}
